﻿using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Partner.Surround.DtoMappers;
using Partner.Surround.Notifications.DtoMapper;

namespace Partner.Surround
{
    [DependsOn(
        typeof(SurroundCoreModule), 
        typeof(AbpAutoMapperModule))]
    public class SurroundApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Modules.AbpAutoMapper().Configurators.Add(FrameDtoMapper.CreateMappings);//基础支撑映射文件
            Configuration.Modules.AbpAutoMapper().Configurators.Add(BaseDtoMapper.CreateMappings);//基础设施映射文件
            Configuration.Modules.AbpAutoMapper().Configurators.Add(NotificationDtoMapper.CreateMappings);//消息通知映射文件
        }

        public override void Initialize()
        {
            var thisAssembly = typeof(SurroundApplicationModule).GetAssembly();

            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddProfiles(thisAssembly)
            );
        }
    }
}
